﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using model;
using Bll;
using System.Web.Security;

public partial class Registere : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnReg_Click(object sender, EventArgs e)
    {
        EnterpriseBll bll = new EnterpriseBll();
        Enterprise enterprise = new Enterprise();
        if (txtEpwd1.Text == txtEpwd2.Text)
        {
            enterprise.Eno = txtEno.Text;
            enterprise.Epwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtEpwd1.Text,"MD5");
            enterprise.Ename = txtEname.Text;
            enterprise.Eintro = txtEintro.Text;
            try
            {
                bll.ZhuCe(enterprise);
                Session["username"] = enterprise.Ename;
                Session["userid"] = enterprise.Eno;
                Session["usergroup"] = "enterprise";
                Response.Write("<script>alert('注册成功！');location.href('Default.aspx');</script>");
            }
            catch (Exception ex)
            {
                string js = "<script>alert('" + ex.Message + "');</script>";
                Response.Write(js);
            }
        }
        else
        {
            Response.Write("<script>alert('两次密码不一致！');</script>");
        }
    }
}